package huoye.shops.huoye.operation.adapter;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.codeideology.android.utils.StringUtils;
import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import huoye.shops.R;
import huoye.shops.huoye.operation.model.VipGustsData;
import huoye.shops.huoye.user.model.User;
import huoye.shops.widget.RoundImageView;

/**
 * Created by uesr on 2017/8/18.
 */

public class VipGuestsAdapter extends RecyclerViewAdapter<VipGuestsAdapter.ViewHolder,VipGustsData> {


    public VipGuestsAdapter(Context context) {
        super(context, R.layout.item_vip_guests);
    }



    @Override
    protected ViewHolder initViewHolder(View view, int i) {
        return new ViewHolder(view);
    }

    @Override
    protected void bindView(final ViewHolder holder, final VipGustsData vipGustsData, int i) {
        if(getContext() != null){
            Glide.with(getContext())
                    .load(vipGustsData.getHeadImg())
                    .dontAnimate()
                    .placeholder(R.mipmap.ic_wait_logo)
                    .error(R.mipmap.ic_error)
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .into(holder.rvHead);
        }
        holder.tvName.setText(vipGustsData.getNickName());
        holder.tvPrlContent.setText(vipGustsData.getPrlContent());
        holder.tvTime.setText("特权到期"+vipGustsData.getEndTime());






       holder.btnEdit.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
               listener.onEditClick(vipGustsData);
           }
       });
        holder.btnDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onDeleteClick(vipGustsData)
                ;
            }
        });


    }


    public class ViewHolder extends RecyclerViewAdapter.ViewHolder {

        @BindView(R.id.item_vip_guests_rv_head)
        public RoundImageView rvHead;

        @BindView(R.id.item_vip_guests_tv_name)
        public TextView tvName;

        @BindView(R.id.item_vip_guests_tv_prl_content)
        public TextView tvPrlContent;
        @BindView(R.id.item_vip_guests_tv_time)
        public TextView tvTime;



        @BindView(R.id.item_vip_guests_btn_edit)
        public Button btnEdit;
        @BindView(R.id.item_vip_guests_btn_delete)
        public Button btnDelete;

        public ViewHolder(View itemView) {
            super(itemView);
        }
    }

    public void setOnVipGuestsListener(OnVipGuestsListener onVipGuestsListener) {
        this.listener = onVipGuestsListener;
    }

    private OnVipGuestsListener listener;

    public interface OnVipGuestsListener {

        void onEditClick(VipGustsData vipGustsData);
        void onDeleteClick(VipGustsData vipGustsData);

    }
}
